<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

        function countDown(time){
            let now = +new Date();//获取当前总毫秒数
            let ipt = +new Date(time);//获取用户输入总毫秒书
            let times = (ipt - now)/1000; //剩下的时间总毫秒数 
            let d = parseInt(times / 60 / 60 / 24);
            d = d < 10 ? '0' +d:d
            let h = parseInt(times / 60 / 60 % 24);
            h = h < 10 ? '0' +h:h
            let m = parseInt(times /  60 % 60);
            m = m < 10 ? '0' +m:m
            let s = parseInt(times % 60);
            s = s < 10 ? '0' +s:s
            return d + '天' + h + '时' + m + '分' + s + '秒'
        }
        console.log(countDown('2021-3-29 12:00:00'));
        let date = new Date();
        console.log(date);
    </script>
</body>
</html>